package com.hr.approval.listener;

import com.hr.approval.entity.ApprovalData;
import com.hr.approval.mapper.ApprovalDataMapper;
import com.hr.system.entity.SysDept;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j //lombok封装
@Component //IOC创建对象
@RocketMQMessageListener(topic = "hr_work_approval",consumerGroup = "hr_work_leader")
public class ApprovalListener implements RocketMQListener<ApprovalData> {

    @Autowired
    private ApprovalDataMapper approvalDataMapper;
    //接收消息
    @Override
    public void onMessage(ApprovalData approvalData) {
        System.err.println("领导端，接收消息："+approvalData.getReporterName());
        approvalDataMapper.insert(approvalData);
    }
}